package com.enjoyor.soa.traffic.rest.efoms.dubbo.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceStatusInfoDto;
import com.enjoyor.soa.traffic.api.service.dubbo.efoms.IDubboDevStatusInfoService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IDevStatusConsumeService;
import com.enjoyor.soa.traffic.util.enums.EnumAppCode;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;
import org.springframework.stereotype.Component;

@Component
public class DevStatusConsumeService implements IDevStatusConsumeService {

	@Reference(version = "1.0.0",timeout = 10000)
    private IDubboDevStatusInfoService dubboDevStatusInfoService;

    /**
     * 修改设备状态信息表（关键字段：设备类别、设备Id、状态信息）
     *
     * @param deviceStatusInfoDto
     * @param username
     * @return
     */
    @Override
    public ResultPojo updateDevStatusInfo(DeviceStatusInfoDto deviceStatusInfoDto, String username) {
        ResultPojo resultPojo;
        try {
            resultPojo = dubboDevStatusInfoService.updateDevStatusInfo(deviceStatusInfoDto,username);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }

    /**
     * 获取设备状态信息
     * @param devCategoryCode 设备类别编号
     * @param devTypeCode 设备类型编号
     * @param devId     设备编号
     * @return
     */
    @Override
    public ResultPojo getDevStatusInfo(String devCategoryCode, String devTypeCode,String devId) {
        ResultPojo resultPojo;
        try {
            resultPojo = dubboDevStatusInfoService.getDevStatusInfo(devCategoryCode, devTypeCode, devId);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }
}
